import { Component, OnInit } from '@angular/core';
import {HeroObject} from "../model/heroObject";
import {HomeService} from "../home/home.service";

@Component({
  selector: 'app-dashboard',
  templateUrl: './dashboard.component.html',   //模板
  styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {

  herolist : HeroObject[] = [];


  constructor( private heroservice: HomeService) {

  }

  ngOnInit() {
   this.getHeroList();
  }

  getHeroList():void{
    this.heroservice.getHeroList().subscribe(hero=>this.herolist = hero.slice(0,4));
  }

}
